mod engine;
mod render;
mod config;
mod localization;
mod scene_manager;
mod asset_manager;
mod ecs;
mod api;
mod js_bridge;

use anyhow::Result;
use crate::js_bridge::JSBridge;
use std::env;

fn main() -> Result<()> {
    // 获取游戏配置文件路径
    let args: Vec<String> = env::args().collect();
    let config_path = if args.len() > 1 {
        args[1].clone()
    } else {
        "games/demo_game.json".to_string()
    };

    // 加载游戏配置
    let config = crate::config::GameConfig::from_file(&config_path)?;
    
    // 创建并运行JavaScript桥接器
    let mut bridge = JSBridge::new(config)?;
    bridge.run()?;
    
    println!("引擎已退出");
    Ok(())
}